package com.xmy.service.imlp;

import com.xmy.dao.AccountDao;
import com.xmy.dao.BaseDao;
import com.xmy.dao.Impl.AccountDaoImpl;
import com.xmy.dao.Impl.MasterDaoImpl;
import com.xmy.dao.Impl.PetDaoImpl;
import com.xmy.dao.MasterDao;
import com.xmy.dao.PetDao;
import com.xmy.entity.Account;
import com.xmy.entity.Master;
import com.xmy.entity.Pet;
import com.xmy.service.Buyable;
import com.xmy.service.MasterService;
import com.xmy.service.Sellable;

public class MasterServiceImpl extends BaseDao implements MasterService,Buyable,Sellable {

    MasterDao masterDao = new MasterDaoImpl();
    AccountDao accountDao = new AccountDaoImpl();
    PetDao petDao = new PetDaoImpl();

    @Override
    public void buy(Pet pet) {
        Account account = new Account();
        account.setPetid(pet.getPetid());
        account.setSid(pet.getSid());
        account.setTypeid(1);
        account.setMid(pet.getMid());
        account.setPrice(pet.getPrice());
        accountDao.addAccountInfo(account);
    }

    @Override
    public void sell(Pet pet) {
        petDao.UpdatePet(pet.getPetid());
    }

    @Override
    public Master login(String id,String pwd) {
        Master master = masterDao.SelLogin(id,pwd);
        return master;
    }
}
